/*
 * Lớp View chung 
 */
package com.casestudy1.view;

import com.casestudy1.main.MainMidlet;
import com.nokia.mid.ui.orientation.Orientation;
import com.sun.lwuit.Form;
import com.sun.lwuit.Graphics;
import com.sun.lwuit.Painter;
import com.sun.lwuit.geom.Rectangle;

/**
 *
 * @author Windsea
 */
public abstract class View extends Form {

    protected MainMidlet midlet;

    public View(MainMidlet midlet) {
        super();
        this.midlet = midlet;


    }

    public void setTheme(String name) {
        getMidlet().refreshTheme();
        getMidlet().loadTheme(name);
    }

    public void lockOrientation() {
        do {

            midlet.displayOrientationChanged(Orientation.ORIENTATION_PORTRAIT);

        } while (getWidth() > getHeight());
    }

    public MainMidlet getMidlet() {
        return midlet;
    }

    class TitleBgPainter implements Painter {

        public void paint(Graphics grphcs, Rectangle rctngl) {
            grphcs.fillLinearGradient(0x333333, 0x444444, 0, 0,
                    rctngl.getSize().getWidth(), rctngl.getSize().getHeight(), false);
        }
    }
}
